//获取应用实例
const app = getApp();
Page({
  onLoad: function (options) {
      var that = this;
      this.setData({
        cat_name: options.cat_name,
        cat_id: options.cat_id,
        keywords: options.keywords
      });
	  	wx.request({
        url: "https://api.160nurse.com/foods/foods?cat_id=" + options.cat_id+"&cat_name=" + options.cat_name + "&keywords=" + options.keywords,
	  		method:'get',
	  		success:function(res){
          that.setData({
            list: res.data.data.list,
            total:res.data.data.total
          });	  			
	  		}
	  	});
			wx.setNavigationBarTitle({
					title: options.cat_name
			});
    wx.setTabBarBadge({
      index: 0,
      text: '1'
    })
  },
  search: function (e) {
    console.log(e.detail);
    wx.redirectTo({
      url: '../Search/SearchList?cat_name=&cat_id=0&keywords=' + e.detail.value,
    })
  },
  onShareAppMessage: function () {
    var nickName = '';
    try {
      nickName = wx.getStorageSync('nickName');
    } catch (e) { }
    return {
      title: nickName + '向你推荐「食材搭配」了解食材的功效、营养及搭配宜忌',
      imageUrl: 'https://resource.160nurse.com/upload/miniprogram/foods.jpeg'
    }
  },
  
})